
window.addEventListener('DOMContentLoaded', () => {
    // validate form
    new JustValidate('.form', {
        rules: {
            name: {
                required: true,
                minLength: 2,
                maxLength: 15
            },
            email: {
                required: true,
                email: true
            },
            tel: {
                required: true,
                function: (name, value) => {
                    const phone = selector.inputmask.unmaskedvalue()
                    return Number(phone) && phone.length === 10
                }
            }
        }
    })
//  mask for phone number
    let selector = document.querySelector("input[type='tel']");
    let im = new Inputmask("+7 (999)-999-99-99");
    im.mask(selector);
    
});
